package com.gooluke.game.enums;

import java.util.function.IntPredicate;

/**
 * @author gooluke
 * description
 * datetime 2025-05-18 1:53
 */
public enum UserType {

    NORMAL(points -> points == 0),
    VIP1(points -> points > 0 && points <= 100),
    VIP2(points -> points > 100 && points <= 1000),
    VIP3(points -> points > 1000 && points <= 10000),
    SVIP(points -> points > 10000),
    ;

    private final IntPredicate predicate;

    UserType(IntPredicate predicate) {
        this.predicate = predicate;
    }

    public static UserType of(int points) {
        for (UserType value : values()) {
            if (value.predicate.test(points)) {
                return value;
            }
        }
        return NORMAL;
    }
}
